package ${package.Controller};

import org.springframework.web.bind.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;
import ${package.Service}.${table.serviceName};
import ${package.Entity}.${entity};
import com.scau.meetingbook.vo.ResultVO;

import java.util.List;

<#if restControllerStyle>
@RestController
<#else>
@Controller
</#if>
@RequestMapping("/${table.entityPath}")
public class ${table.controllerName} {

    @Autowired
    private ${table.serviceName} ${table.serviceName?uncap_first};

    @PostMapping("/insert${entity}")
    public ResultVO insert${entity}(@RequestBody ${entity} ${entity?uncap_first}) throws Exception {
        return ${table.serviceName?uncap_first}.insert${entity}(${entity?uncap_first});
    }

    @GetMapping("/get${entity}ById")
    public ResultVO<${entity}> get${entity}ById(Integer id) throws Exception {
        return ${table.serviceName?uncap_first}.get${entity}ById(id);
    }

    @PutMapping("/update${entity}ById")
    public ResultVO update${entity}ById(@RequestBody ${entity} ${entity?uncap_first}) throws Exception {
        return ${table.serviceName?uncap_first}.update${entity}ById(${entity?uncap_first});
    }

    @DeleteMapping("/delete${entity}ById")
    public ResultVO delete${entity}ById(Integer id) throws Exception {
        return ${table.serviceName?uncap_first}.delete${entity}ById(id);
    }
}